package day3.demo5_减法器;

import java.util.concurrent.CountDownLatch;

public class Test {
    public static void main(String[] args) {
        CountDownLatch cd = new CountDownLatch(6);
        String[] arr = "韩,赵,魏,楚,燕,齐,秦".split(",");
        for (String msg : arr) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    if(msg.equals("秦")){
                        try {
                            cd.await();
                        } catch (InterruptedException e) {}
                        System.out.println("项羽灭秦。。。。。。。");
                    }else {
                        System.out.println(Thread.currentThread().getName() + "被秦灭亡");
                        cd.countDown();//减一
                    }
                }
            },msg).start();
        }
    }
}
